package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class TravelCommend extends BaseDomain {
    public static final int TYPE_WEEKDAY = 2;
    public static final int TYPE_MONTH = 1;
    public static final int TYPE_STRATEGY = 3;

    private Long travelId;

    private String title;
    private String subTitle;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date schedule;

    private Integer type;

    public String getTypeName(){
        String temp = "每周推荐";
        if(type == TYPE_MONTH){
            temp = "每月推荐";
        }else if(type == TYPE_STRATEGY){
            temp = "攻略推荐";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("travelId",travelId);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type", type);
        return JSONUtils.toJSONString(map);
    }
}